package com.globallogic.university.events;

import com.globallogic.university.people.StudentGroup;
import com.globallogic.university.people.Teacher;
import com.globallogic.university.subject.Subject;
import com.globallogic.university.venues.Auditorium;
/**
 * Class represents an academic event with a generic set of information about it.
 * It is inherited by other classes in the package.
 * 
 * @author vladyslav.bachurin
 *
 */
public class Event {
	private StudentGroup group;
	private Auditorium auditorium;
	private Subject subject;
	private Teacher lecturer;
	private DaysOfWeek dayOfWeek;
	private Integer timeSlotNumber;
	
	public static enum DaysOfWeek {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY}
	
	public Event(StudentGroup group, DaysOfWeek dayOfWeek, Integer timeSlotNumber, Auditorium auditorium, Subject subject, Teacher lecturer) {
		this.auditorium = auditorium;
		this.subject = subject;
		this.lecturer = lecturer;
		this.dayOfWeek = dayOfWeek;
		this.timeSlotNumber = timeSlotNumber;
		this.group = group;
	}

	public Event() {

	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((auditorium == null) ? 0 : auditorium.hashCode());
		result = prime * result
				+ ((dayOfWeek == null) ? 0 : dayOfWeek.hashCode());
		result = prime * result
				+ ((lecturer == null) ? 0 : lecturer.hashCode());
		result = prime * result + ((subject == null) ? 0 : subject.hashCode());
		result = prime * result
				+ ((timeSlotNumber == null) ? 0 : timeSlotNumber.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Event other = (Event) obj;
		if (auditorium == null) {
			if (other.auditorium != null)
				return false;
		} else if (!auditorium.equals(other.auditorium))
			return false;
		if (dayOfWeek != other.dayOfWeek)
			return false;
		if (lecturer == null) {
			if (other.lecturer != null)
				return false;
		} else if (!lecturer.equals(other.lecturer))
			return false;
		if (subject == null) {
			if (other.subject != null)
				return false;
		} else if (!subject.equals(other.subject))
			return false;
		if (timeSlotNumber == null) {
			if (other.timeSlotNumber != null)
				return false;
		} else if (!timeSlotNumber.equals(other.timeSlotNumber))
			return false;
		return true;
	}
	public Auditorium getAuditorium() {
		return auditorium;
	}
	public void setAuditorium(Auditorium auditorium) {
		this.auditorium = auditorium;
	}
	public Subject getSubject() {
		return subject;
	}
	public void setSubject(Subject subject) {
		this.subject = subject;
	}
	public Teacher getLecturer() {
		return lecturer;
	}
	public void setLecturer(Teacher lecturer) {
		this.lecturer = lecturer;
	}
	@Override
	public String toString() {
		return String.format("Slot [%s] %s %s %s", getTimeSlot(), getAuditorium(), getSubject(), getLecturer());
	}

	public void setDayOfWeek(DaysOfWeek dayOfWeek) {
		this.dayOfWeek= dayOfWeek; 
	}
	
	public DaysOfWeek getDayOfWeek() {
		return dayOfWeek;
	}

	public void setTimeSlot(int timeSlotNumber) {
		if (timeSlotNumber > 6)
			throw new RuntimeException();
		this.timeSlotNumber = timeSlotNumber;	
	}

	public Integer getTimeSlot() {
		return timeSlotNumber;
	}

	public StudentGroup getGroup() {
		return group;
	}

	public void setGroup(StudentGroup group) {
		this.group = group;
	}
	
	
}
